#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://oj33.cn/contest.php?cid=1075
int board[9][9];
int x_[8] = { -2,-2,-1,-1,1,1,2,2 };
int y_[8] = { 1,-1,2,-2,2,-2,1,-1 };
int sum;char a1;int b1;
int ans =1<<28;
int f = 0;
void change()
{
	if (sum < ans)
	{
		ans = sum;
	}
}
void dfs(int x, int y)
{
	
	if (ans < sum)return;
	for (int i=0;i<8;i++)
	{
		if (!board[x + x_[i]][y + y_[i]] && x + x_[i] >= 1 && x + x_[i] <= 8 && y + y_[i] >= 1 && y + y_[i] <= 8)
		{
			sum++;
			board[x + x_[i]][y + y_[i]] = 1;
			if (x + x_[i] == a1 - 'a'+1 && y + y_[i] == b1)
			{
				change();
			}
			else
				dfs(x + x_[i],y + y_[i]);
			sum--;
			board[x + x_[i]][y + y_[i]] = 0;
			
		}
	}

}
int main()
{
	char a;
	int b;
	while (cin>>a>>b>>a1>>b1)
	{
		if (a == a1 && b == b1)
		{
			cout << "To get from " << a << b << " to " << a1 << b1 << " takes " << 0 << " knight moves." << endl;
			continue;
		}ans = 1 << 28;
		for (int i = 1; i < 9; i++)
			for (int j = 0; j < 9; j++)
				board[i][j] = 0;
		board[a - 'a' + 1][b]=1;
		dfs(a - 'a'+1, b);
	
	 cout << "To get from "<<a<<b<<" to "<<a1<<b1<<" takes "<<ans<<" knight moves." << endl;
	}

	return 0;
}